<?php
$arr = [
    '1'=>[
        'name'=>'the1' 
    ],
    '2'=>[
        'name'=>'the2',
        'child'=>[
            '21'=>[
                'name'=>'the21' 
            ],
            '22'=>[
                'name'=>'the22' 
            ],
        ],
    ],
    '3'=>[
        'name'=>'the3' 
    ],
];
$a = function($list, $a)
{
    if(empty($list))
        return false;
    foreach($list as $key => $item){
        echo '<hr />';
        echo $key.'<br />';
        echo $item['name'].'<br />';
        if(!empty($item['child']))
            $a($item['child'], $a).'<br />';
        echo '<hr />';
    }
    return;
};
$a($arr, $a);

